Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix decoding error with trailing comment extension blocks #12

Merged
merged 3 commits into from
Feb 18, 2024

Conversation

olivervogel
Copy link
Member

The GIF files that can be found on the Internet come in a wide variety of forms. Some strictly adhere to the original specification, others do not and differ in the actual sequence of blocks or their number.

For this reason, my decoder has a kind of "virtual" FrameBlock, which can contain all possible blocks in different order that occur in a GIF animation.

  • Graphic Control Extension
  • Image Description
  • Local Color Table
  • Image Data Block
  • Plain Text Extension
  • Application Extension
  • Comment Extension

The TableBasedImage block, which is a chain of ImageDescriptor, (Local Color Table) and ImageData, is used as a feature for terminating a FrameBlock.

So far I have only seen GIF files that follow this scheme. However, there was one example where one (or more) comment extensions were added before the end. Here the decoding process failed.

This fix also adds "global comments" that are not part of my FrameBlock and are appended to the GifDataStream afterwards.

The GIF files that can be found on the Internet come in a wide variety
of forms. Some strictly adhere to the original specification, others do
not and differ in the actual sequence of blocks or their number.

For this reason, my decoder has a kind of "virtual" FrameBlock, which
can contain all possible blocks in different order that occur in a GIF
animation.

- Graphic Control Extension
- Image Description
- Local Color Table
- Image Data Block
- Plain Text Extension
- Application Extension
- Comment Extension

The TableBasedImage block, which is a chain of ImageDescriptor, (Local
Color Table) and ImageData, is used as a feature for terminating a
FrameBlock.

So far I have only seen GIF files that follow this scheme. However,
there was one example where one (or more) comment extensions were added
before the end. Here the decoding process failed.

This fix also adds "global comments" that are not part of my FrameBlock
and are appended to the GifDataStream afterwards.
@olivervogel olivervogel merged commit c2b07d1 into main Feb 18, 2024
3 checks passed
@olivervogel olivervogel deleted the fix/fix-decoding-error-with-trailing-comment-blocks branch February 18, 2024 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Opening an animated GIF results in DecoderException: Unable to decode Data Block
1 participant